package com.moujitx.wecom.common;

import lombok.*;

/**
 * Function:消息统一返回接口
 * Author: MOUJITX
 * Date: 2023/9/17 21:59
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    public static final Integer CODE_SUCCESS_OK = 200;
    public static final Integer CODE_ERROR_BAD_REQUEST = 400;
    public static final Integer CODE_ERROR_SERVER_ERROR = 500;

    public static final String MSG_REQUEST_SUCCESS = "Request Success";
    public static final String MSG_BAD_REQUEST = "Bad Request";
    public static final String MSG_SERVER_ERROR = "Server Error";

    private Integer code;
    private String message;
    private Object data;

    public static Result ok(String data) {
        return new Result(CODE_SUCCESS_OK, MSG_REQUEST_SUCCESS, data);
    }
    
    public static Result ok(Object data) {
        return new Result(CODE_SUCCESS_OK, MSG_REQUEST_SUCCESS, data);
    }

    public static Result badRequest(String data) {
        return new Result(CODE_ERROR_SERVER_ERROR, MSG_BAD_REQUEST, data);
    }

    public static Result serverError(String data) {
        return new Result(CODE_ERROR_SERVER_ERROR, MSG_SERVER_ERROR, data);
    }
}